package org.vacoor.nothing.misc.express.usps.api.rate.v4;

import org.vacoor.nothing.misc.express.usps.api.data.UspsError;
import org.vacoor.nothing.misc.express.usps.api.data.type.UspsFirstClassMailType;
import org.vacoor.nothing.misc.express.usps.api.data.type.UspsContainer;
import org.vacoor.nothing.misc.express.usps.api.support.BooleanAdapter;

import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.List;

/**
 * USPS 价格计算 - 包裹信息
 *
 * @author vacoor
 */
@XmlAccessorType(XmlAccessType.FIELD)
public class RatePackage {
    @XmlID
    @XmlAttribute(name = "ID", required = true)
    private String id;          // Package Id
    @XmlElement(name = "Service", required = true)
    private Service service;    // required, 服务类型
    /**
     * optional
     * 当 [Service='FIRST CLASS'] or [Service='FIRST CLASS COMMERCIAL’],
     * or [Service='FIRST CLASS HFP COMMERCIAL’] 时为 required
     */
    @XmlElement(name = "FirstClassMailType")
    private UspsFirstClassMailType firstClassMailType;
    @XmlElement(name = "ZipOrigination", required = true)
    private String zipOrigination;  // required, 出发地 zip code, pattern: \d{5}
    @XmlElement(name = "ZipDestination", required = true)
    private String zipDestination;  // required, 目的地 zip code, pattern: \d{5}
    @XmlElement(name = "Pounds")
    private String pounds;  // required, 包裹重量-英镑, 16 * pounds + ounces <= 70 (0 ~ 70)
    @XmlElement(name = "Ounces", required = true)
    private String ounces;  // required, 包裹重量-盎司, 同上, <= 70 pounds (1120.0 ounces)
    /**
     * required, 指定特殊容器, 可能会影响邮费
     */
    @XmlElement(name = "Container", required = true)
    private UspsContainer container = UspsContainer.VARIABLE;
    /**
     * 尺寸:
     * REGULAR: Package dimensions are 12’’ or less; (常规 <= 12)
     * LARGE: Any package dimension is larger than 12’’. (大 >= 12)
     */
    @XmlElement(name = "Size")
    private Size size;
    /**
     * width/length/height/girth 用于当 Size = LARGE 时指定包裹大小(必须,单位英寸)
     */
    @XmlElement(name = "Width")
    private String width;
    @XmlElement(name = "Length")
    private String length;
    @XmlElement(name = "Height")
    private String height;
    @XmlElement(name = "Girth")
    private String girth;
    /**
     * 当 Revision=2时有效，Used to determine availability and cost of extra services.
     */
    @XmlElement(name = "Value")
    private String value;
    /**
     * 当 Revision=2时有效,Collect on delivery amount.  Used to determine availability and cost of extra services.
     */
    @XmlElement(name = "AmountToCollect")
    private String amountToCollect;
    @XmlElementWrapper(name = "SpecialServices")
    @XmlElement(name = "SpecialService")
    private List<SpecialService> specialServices;   // 特殊服务
    @XmlElement(name = "Content")
    private Content content;
    @XmlElement(name = "GroundOnly")
    @XmlJavaTypeAdapter(BooleanAdapter.class)
    private Boolean groundOnly;
    @XmlElement(name = "SortBy")
    private SortBy sortBy;
    @XmlElement(name = "Machinable")
    @XmlJavaTypeAdapter(BooleanAdapter.class)
    private Boolean machinable;
    @XmlElement(name = "ReturnLocations")
    @XmlJavaTypeAdapter(BooleanAdapter.class)
    private Boolean returnLocations;// = Boolean.TRUE;
    @XmlElement(name = "returnServiceInfo")
    @XmlJavaTypeAdapter(BooleanAdapter.class)
    private Boolean returnServiceInfo;
    @XmlElement(name = "DropOffTime")
    private String dropOffTime; // HH:mm eg: 13:45
    @XmlElement(name = "ShipDate")
    private ShipDate shipDate;

    /**
     * response attribute
     */
    @XmlElement(name = "Zone")
    private String zone;
    @XmlElement(name = "Postage")
    private Postage postage;
    @XmlElement(name = "Restrictions")
    private String restrictions;
    @XmlElement(name = "Error")
    private UspsError uspsError;

    public static RatePackage create() {
        return new RatePackage();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Service getService() {
        return service;
    }

    public void setService(Service service) {
        this.service = service;
    }

    public UspsFirstClassMailType getFirstClassMailType() {
        return firstClassMailType;
    }

    public void setFirstClassMailType(UspsFirstClassMailType firstClassMailType) {
        this.firstClassMailType = firstClassMailType;
    }

    public String getZipOrigination() {
        return zipOrigination;
    }

    public void setZipOrigination(String zipOrigination) {
        this.zipOrigination = zipOrigination;
    }

    public String getZipDestination() {
        return zipDestination;
    }

    public void setZipDestination(String zipDestination) {
        this.zipDestination = zipDestination;
    }

    public String getPounds() {
        return pounds;
    }

    public void setPounds(String pounds) {
        this.pounds = pounds;
    }

    public String getOunces() {
        return ounces;
    }

    public void setOunces(String ounces) {
        this.ounces = ounces;
    }

    public UspsContainer getContainer() {
        return container;
    }

    public void setContainer(UspsContainer container) {
        this.container = container;
    }

    public Size getSize() {
        return size;
    }

    public void setSize(Size size) {
        this.size = size;
    }

    public String getWidth() {
        return width;
    }

    public void setWidth(String width) {
        this.width = width;
    }

    public String getLength() {
        return length;
    }

    public void setLength(String length) {
        this.length = length;
    }

    public String getHeight() {
        return height;
    }

    public void setHeight(String height) {
        this.height = height;
    }

    public String getGirth() {
        return girth;
    }

    public void setGirth(String girth) {
        this.girth = girth;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getAmountToCollect() {
        return amountToCollect;
    }

    public void setAmountToCollect(String amountToCollect) {
        this.amountToCollect = amountToCollect;
    }

    public List<SpecialService> getSpecialServices() {
        return specialServices;
    }

    public void setSpecialServices(List<SpecialService> specialServices) {
        this.specialServices = specialServices;
    }

    public Content getContent() {
        return content;
    }

    public void setContent(Content content) {
        this.content = content;
    }

    public Boolean getGroundOnly() {
        return groundOnly;
    }

    public void setGroundOnly(Boolean groundOnly) {
        this.groundOnly = groundOnly;
    }

    public SortBy getSortBy() {
        return sortBy;
    }

    public void setSortBy(SortBy sortBy) {
        this.sortBy = sortBy;
    }

    public Boolean getMachinable() {
        return machinable;
    }

    public void setMachinable(Boolean machinable) {
        this.machinable = machinable;
    }

    public Boolean getReturnLocations() {
        return returnLocations;
    }

    public void setReturnLocations(Boolean returnLocations) {
        this.returnLocations = returnLocations;
    }

    public Boolean getReturnServiceInfo() {
        return returnServiceInfo;
    }

    public void setReturnServiceInfo(Boolean returnServiceInfo) {
        this.returnServiceInfo = returnServiceInfo;
    }

    public String getDropOffTime() {
        return dropOffTime;
    }

    public void setDropOffTime(String dropOffTime) {
        this.dropOffTime = dropOffTime;
    }

    public ShipDate getShipDate() {
        return shipDate;
    }

    public void setShipDate(ShipDate shipDate) {
        this.shipDate = shipDate;
    }

    public String getZone() {
        return zone;
    }

    public void setZone(String zone) {
        this.zone = zone;
    }

    public Postage getPostage() {
        return postage;
    }

    public void setPostage(Postage postage) {
        this.postage = postage;
    }

    public String getRestrictions() {
        return restrictions;
    }

    public void setRestrictions(String restrictions) {
        this.restrictions = restrictions;
    }

    public UspsError getUspsError() {
        return uspsError;
    }

    public void setUspsError(UspsError uspsError) {
        this.uspsError = uspsError;
    }
}
